package com.itheima.test;

public class Test5 {
    public static void main(String[] args) {
        //给定两个以字符串的非负整数num1和num2，返回num1和num2的乘积，他们的乘积也表示为字符串格式
        //注意：需要用已有的知识完成

        //1.给定两个字符串
        String num1 = "1200";
        String num2 = "100";

        //2.调用方法，把他们化为整数
        int number1 = toint(num1);
        int number2 = toint(num2);

        //3.把他们的乘积化为字符串
        String result = tostring(number1 * number2);

        //4.打印结果
        System.out.println(result);
    }

    //定义一个方法把整数变为字符串
    public static String tostring(int number) {
        StringBuilder sb = new StringBuilder();
        while (number != 0) {
            sb.append(number % 10);
            number /= 10;
        }
        String str = sb.reverse().toString();
        return str;
    }

    //定义一个把字符串化为整数的方法
    public static int toint(String str) {
        int sum = 0;
        for (int i = 0; i < str.length(); i++) {
            int number = str.charAt(i) - '0';
            sum = sum * 10 + number;
        }
        return sum;
    }
}
